//
// Created by 赵李言 on 2022/4/11.
//

#include <iostream>
#include <algorithm>
#include <vector>
using  namespace  std;
struct p{
    int id, vote=0;
};
vector<p> vote;
int n,m;
int main(){
    vote.resize(10050);
    cin>>n>>m;
    for (int i = 0; i < 10050; ++i) {
        vote[i].id=i;
    }
    for (int i = 0; i < m; ++i) {
        int id;
        cin>>id;
        vote[id].vote++;
    }
    sort(vote.begin(), vote.end(), [](p a,p b)->bool{
        return a.vote<b.vote;
    });
    auto max= vote.back();
    if(max.vote>m/2){
        cout<<max.id;
    }
    else
        cout<<-1;
}